package com.szx.usercenter.controller;

import com.szx.usercenter.domain.SysRole;
import com.szx.usercenter.service.SysUserRoleService;
import com.szx.usercenter.util.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author songzx
 * @date 2024/5/19
 * @apiNote
 */
@Api(tags = "用户角色管理")
@RestController
@RequestMapping("sysUserRole")
public class SysUserRoleController {
    @Autowired
    SysUserRoleService sysUserRoleService;

    @ApiOperation("分配用户角色")
    @PostMapping("setUserRole")
    public Response addUserRole(@RequestBody List<Long> roleIds, Long userId) {
        return sysUserRoleService.addUserRole(roleIds, userId);
    }

    @ApiOperation("根据用户ID查询角色列表")
    @GetMapping("getUserRoleList")
    public Response getUserRoleList(Long userId) {
        List<SysRole> sysUserRoleList = sysUserRoleService.getUserRoleList(userId);
        return Response.rspData(sysUserRoleList);
    }
}
